/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package scm.rawMaterialPurchasing.managedbean;

import java.io.IOException;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.primefaces.event.ToggleEvent;
import scm.rawMaterialPurchasing.entity.RawMaterialRequirementEntity;
import scm.rawMaterialPurchasing.session.RawMaterialPurchasingSessionBean;

/**
 *
 * @author ReinforceII
 */
@ManagedBean
@ViewScoped
public class SelectRawMaterialRequirementManagedBean {

    @EJB
    RawMaterialPurchasingSessionBean rawMaterialPurchasingSessionBean;

    /** Creates a new instance of SelectRawMaterialRequirementManagedBean */
    public SelectRawMaterialRequirementManagedBean() {
    }

    public List<RawMaterialRequirementEntity> getRawMaterialRequirements() {

        return rawMaterialPurchasingSessionBean.getAllRawMaterialRequirements();
    }
        public List<RawMaterialRequirementEntity> getAllRawMaterialRequirements() {

        return rawMaterialPurchasingSessionBean.getAllTheRawMaterialRequirements();
    }

    public void createRawMaterialPurchasingOrder(RawMaterialRequirementEntity rawMaterialRequirement) throws IOException {

        FacesContext.getCurrentInstance().getExternalContext().getFlash().put("rawMaterialRequirement", rawMaterialRequirement);
        FacesContext.getCurrentInstance().getExternalContext().redirect("createRawMaterialPurchasingOrder.xhtml");
    }
     public void handleToggle(ToggleEvent event) {
        FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Fieldset Toggled", "Visibility:" + event.getVisibility());

        FacesContext.getCurrentInstance().addMessage(null, msg);
    }
}
